package com.feishu.service.impl;

import cn.hutool.core.lang.UUID;
import com.feishu.mapper.FeiShuObjectMapper;
import com.feishu.service.FeiShuObjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;


@Service
public class FeiShuObjectServiceImpl implements FeiShuObjectService {
    @Autowired
    FeiShuObjectMapper feiShuObjectMapper;


    @Override
    public Integer add(Map<String, Object> map) {
        return feiShuObjectMapper.add(map);
    }

    @Override
    public List<Map<String,Object>> list(Map<String, Object> map) {
        return feiShuObjectMapper.list(map);
    }

    @Override
    public Integer edit(Map<String, Object> map) {
        return feiShuObjectMapper.edit(map);
    }

    @Override
    public Integer delete(Map<String, Object> map) {
        return feiShuObjectMapper.delete(map);
    }

    @Override
    public Integer addLink(Map<String, Object> map) {
        return feiShuObjectMapper.addLink(map);
    }

    @Override
    public Integer editLink(Map<String, Object> map) {
        return feiShuObjectMapper.editLink(map);
    }

    @Transactional
    @Override
    public void addOption(Map<String, Object> map) {
        String uuid= UUID.fastUUID().toString();
        map.put("id", uuid);
        feiShuObjectMapper.add(map);
        map.put("id", UUID.fastUUID().toString());
        map.put("setting_id", map.get("setting"));
        map.put("k3cloud_id", uuid);
        feiShuObjectMapper.addLink(map);
    }

    @Transactional
    @Override
    public void editOption(Map<String, Object> map) {
        feiShuObjectMapper.editLink(map);
        feiShuObjectMapper.edit(map);
    }

    @Override
    public Integer addEnum(Map<String, Object> map) {
        return feiShuObjectMapper.addEnum(map);
    }

    @Override
    public Integer addEnumSelect(List<Map<String, Object>> list) {
        return feiShuObjectMapper.addEnumSelect(list);
    }

    @Transactional
    @Override
    public void addEnumType(Map<String, Object> map,List<Map<String, Object>> list) {
        feiShuObjectMapper.addEnum(map);
        feiShuObjectMapper.addEnumSelect(list);

    }

    @Transactional
    @Override
    public void updateEnumType(Map<String, Object> map, List<Map<String, Object>> list) {
        feiShuObjectMapper.updateEnum(map);
        feiShuObjectMapper.deleteEnumSelect(map);
        feiShuObjectMapper.addEnumSelect(list);
    }

    @Transactional
    @Override
    public void deleteEnumType(Map<String, Object> map, List<Map<String, Object>> list) {
        feiShuObjectMapper.deleteEnumt(map);
        feiShuObjectMapper.deleteEnumSelect(map);
    }

    @Override
    public Integer updateEnum(Map<String, Object> map) {
        return feiShuObjectMapper.updateEnum(map);
    }

    @Override
    public Integer deleteEnumSelect(Map<String, Object> map) {
        return feiShuObjectMapper.deleteEnumSelect(map);
    }

    @Override
    public Integer deleteEnumt(Map<String, Object> map) {
        return feiShuObjectMapper.deleteEnumt(map);
    }

    @Override
    public List<Map<String, Object>> getEnum(Map<String, Object> map) {
        return feiShuObjectMapper.getEnum(map);
    }

    @Override
    public List<Map<String, Object>> getEnumSelect(Map<String, Object> map) {
        return feiShuObjectMapper.getEnumSelect(map);
    }

    @Override
    public Integer addOutSettingEnum(Map<String, Object> map) {
        return feiShuObjectMapper.addOutSettingEnum(map);
    }

    @Override
    public List<Map<String, Object>> getOutEnumSelect(Map<String, Object> map) {
        return feiShuObjectMapper.getOutEnumSelect(map);
    }

    @Override
    public Integer editOutPlmPartById(Map<String, Object> map) {
        return feiShuObjectMapper.editOutPlmPartById(map);
    }

    @Override
    public Integer addInSettingEnum(Map<String, Object> map) {
        return feiShuObjectMapper.addInSettingEnum(map);
    }

    @Override
    public List<Map<String, Object>> getInEnumSelect(Map<String, Object> map) {
        return feiShuObjectMapper.getInEnumSelect(map);
    }


}
